#ifndef RoAbstractModule__h
#define RoAbstractModule__h


#include "RoXmlStream.h"

class RoAbstractComponent;


class RoAbstractModule:
    public QObject
{
    Q_OBJECT
    
    Q_PROPERTY( QString name
                READ name
                WRITE setName )

public:
    
    typedef QObject super;
    
    bool logTraffic;

    explicit RoAbstractModule(QObject * parent = 0);
    ~RoAbstractModule();
    
    virtual void disconnectFromNetwork() = 0;

    virtual bool isConnected() const = 0;

    QString name() const
    {
        return objectName();
    }

    void setName(QString name)
    {
        setObjectName(name);
    }

    /// Находит компонент с заданным именем.
    /// Если такого нет, возвращает 0.
    RoAbstractComponent * findComponent(QString name);

    QList<RoAbstractComponent*> findComponents();

    virtual RoStanzaId sendStanza(RoStanza stanza) = 0;

protected:

    /// Can be overloaded to receive presence stanzas with the source stream.
    virtual void presenceEvent(RoXmlStream * stream, RoInfoStanza stanza);

    void recieve_own_stanza(RoStanza stanza);

private slots:

    virtual void recieve_stanza(RoStanza stanza) = 0;

}; // class RoAbstractModule


#endif // RoAbstractModule__h
